package com.tds.wechathelper.filter;

import com.tds.wechathelper.filter.impl.FirstInnerFilter;
import com.tds.wechathelper.filter.impl.NullFilter;

public abstract class AbstractFilterChain implements FilterChain , Filter{

	protected static Filter NULL_FILTER = new NullFilter();
	protected static Filter DISPACHER_FILTER = new FirstInnerFilter();

	public abstract Filter nextFilter();

	public Filter next() {
		Filter filter = nextFilter();
		return filter == null ? NULL_FILTER : filter;
	}

	@Override
	public void doFilter(String msg) {
		next().doFilter(this, msg);
	}

	@Override
	public void doFilter(FilterChain chain, String msg) {
		doFilter(msg);
		chain.doFilter(msg);
	}
	
}
